import Vue from 'vue'
import Router from 'vue-router'
import routers from './router'

Vue.use(Router)

const routes = new Router({
  routes: routers
})

routes.beforeEach((to, from, next) => {
  console.log(to);
  if (to.matched.length === 0) {
    next('/404')
  } else {
    next();
  }
})

routes.afterEach(to => {
  window.scrollTo(0, 0)
})

export default routes
